package com.vecspace.statistics.counter;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**记录一个和时间有关的数量
 * @author: wanghua
 */
public class TimeCount implements Comparable<TimeCount>{
	
	public TimeCount(Date time, long count) {
		this.time = time;
		this.count = count;
	}
	
	private Date time;
	private long count;
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public long getCount() {
		return count;
	}
	public void setCount(long count) {
		this.count = count;
	}
	
	/**时间字符串yyyy-MM-dd HH:mm:ss
	 * @return 
	 * @author: wanghua
	 */
	public String getFormatTimeString() {
		if(time == null)return "";
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String s = df.format(time);
		return s;
	}
	
	@Override
	public int compareTo(TimeCount other) {
		if(other == null)return 1;
		if(this.time == null)return -1;
		return this.time.compareTo(other.time);		
	}
	
	
	
}
